#include "encoder.h"
#include "decoder.h"
#include "defs.h"
#include "unistd.h"
#include "test.h"

int verbose;

int
main(int argc, char *argv[])
{
	int enc = 1;
	int opt;
	verbose = 0;

	while ((opt = getopt(argc, argv, "v:ted")) != -1) {
		switch(opt) {
			case 'v':
				verbose = atoi(optarg);
				break;
			case 'e':
				enc = 1;
				break;
			case 'd':
				enc = 0;
				break;
            case 't':
                printf("begin to evaluate");
                evaluate();
                return 0;
			case '?':
				if (opt == 'v')
					printf("Missing verbose level after -v\n");
				break;
		}
	}

	if ((argc - optind) != 2) {
		printf("Input file or output file not specified\n");
		return -1;
	}

	char *infile = argv[optind];
	char *outfile = argv[optind+1];

	if (enc) {
		printf("Encode with dict size: %d, input: %s, output: %s\n", DICT_SIZE, infile, outfile);
		encode(infile, outfile);
	}
	else{
		printf("Decode with dict size: %d, input: %s, output: %s\n", DICT_SIZE, infile, outfile);
		decode(infile, outfile);
	}

    return 0;
}
